package cn.monkey.transport.mq.redisson;

import cn.monkey.transport.core.AbstractExchangeManager;
import cn.monkey.transport.core.ExchangeFactory;

public abstract class AbstractRedissonExchangeManager<EXCHANGE extends RedissonExchange>
        extends AbstractExchangeManager<RedissonTransportConfig, EXCHANGE>
        implements RedissonExchangeManager<EXCHANGE> {
    public AbstractRedissonExchangeManager(ExchangeFactory<RedissonTransportConfig, EXCHANGE> factory) {
        super(factory);
    }

    @Override
    public EXCHANGE findOrCreate(String key, RedissonTransportConfig redissonTransportConfig) {
        return super.exchangeMap.computeIfAbsent(key, (k) -> super.factory.apply(k, null, redissonTransportConfig));
    }
}
